<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div class="tags-picker" v-cloak>
        <el-form-item label="选择标签">
            <el-select filterable multiple v-model="tagIds" placeholder="请选择" size="mini">
                <el-option filterable v-for="item in tags" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
            </el-select>
        </el-form-item>
    </div>
</template>

<script>
import { getTagList } from "@/api/tag";

export default {
    data () {
        return {
            tags: [],
            loading: false,
        };
    },
    props: {
        value: { type: Array, default: [] },
    },

    mounted: function () {
        this.loadData();
    },

    computed: {
        tagIds: {
            get () {
                return this.value || [];
            },
            set (v) {
                this.$emit("input", v);
            },
        },
    },

    methods: {
        loadData: function () {
            this.loading = true;
            getTagList().then((res) => {
                this.tags = res.data.result;
                this.loading = false;
            });
        },
    },
};
</script>

<style scoped></style>
